import 'package:environmental_les_app/common/style/colours.dart';
import 'package:flutter_clx_base/flutter_clx_base.dart';

import 'index.dart';

class PersonalInfoPage extends GetView<PersonalInfoController> {
  const PersonalInfoPage({super.key});

  // 主视图
  Widget _buildView() {
    return Stack(
      children: [
        Container(
          height: 255,
          decoration: BoxDecoration(
            image: DecorationImage(
              image: AssetImage(ImageUtils.getImgPath("bg_home_top")),
              fit: BoxFit.cover,
            ),
          ),
        ),
        SafeArea(
          child: Column(
            children: [
              const MyPageAppBar(
                backgroundColor: Colors.transparent,
                title: "信息查看",
              ),
              vGap30,
              Stack(
                clipBehavior: Clip.none,
                children: [
                  Container(
                    margin: const EdgeInsets.symmetric(horizontal: 16),
                    padding: const EdgeInsets.only(top: 50, bottom: 16),
                    decoration: BoxDecoration(
                      color: Colors.white,
                      borderRadius: BorderRadius.circular(12),
                    ),
                    child: Column(
                      children: [
                        Row(
                          mainAxisAlignment: MainAxisAlignment.center,
                          children: [
                            const Text(
                              "小猪妖",
                              style: TextStyle(
                                color: Colours.text171A1D,
                                fontSize: 18,
                                fontWeight: FontWeight.w500,
                              ),
                            ),
                            hGap8,
                            Container(
                              padding: const EdgeInsets.symmetric(
                                  horizontal: 6, vertical: 2),
                              decoration: BoxDecoration(
                                color: Colours.bgCBDCF8,
                                borderRadius: BorderRadius.circular(4),
                              ),
                              child: Row(
                                children: [
                                  ImageWidget.loadAssetImage("ic_mine_position",
                                      width: 16, height: 16),
                                  hGap2,
                                  const Text(
                                    "大队长",
                                    style: TextStyle(
                                      color: Colours.textC4C,
                                      fontSize: 12,
                                      fontWeight: FontWeight.w500,
                                    ),
                                  ),
                                ],
                              ),
                            ),
                          ],
                        ),
                        vGap6,
                        Row(
                          mainAxisAlignment: MainAxisAlignment.center,
                          children: [
                            ImageWidget.loadAssetImage("ic_mine_company",
                                width: 16, height: 16),
                            hGap2,
                            const Text(
                              "准格尔旗环境监察大队",
                              style: TextStyle(
                                color: Colours.text969,
                                fontSize: 14,
                                fontWeight: FontWeight.w400,
                              ),
                            ),
                          ],
                        ),
                        vGap16,
                      ],
                    ),
                  ),
                  Positioned(
                    left: MediaQuery.of(Get.context!).size.width / 2 - 35,
                    top: -35,
                    child: ImageWidget.loadAssetImage("ic_mine_avatar",
                        width: 70, height: 70),
                  ),
                ],
              ),
              Container(
                width: double.infinity,
                margin: const EdgeInsets.only(top: 20, left: 16, right: 16),
                padding:
                    const EdgeInsets.symmetric(horizontal: 16, vertical: 12),
                decoration: BoxDecoration(
                  color: Colors.white,
                  borderRadius: BorderRadius.circular(8),
                ),
                child: Column(
                  crossAxisAlignment: CrossAxisAlignment.start,
                  children: [
                    _infoRow("所在部门", "准格尔旗环境监察大队"),
                    vGap8,
                    _infoRow("联系电话", "19788987789"),
                    vGap8,
                    _infoRow("邮箱", "1786886666@163.com"),
                  ],
                ),
              ),
            ],
          ),
        ),
      ],
    );
  }

  Widget _infoRow(String label, String value) {
    return Row(
      children: [
        Text(
          label,
          style: const TextStyle(
            color: Colours.text969,
            fontSize: 14,
            fontWeight: FontWeight.w400,
          ),
        ),
        hGap16,
        Expanded(
          child: Text(
            value,
            style: const TextStyle(
              color: Colours.textC4C,
              fontSize: 14,
              fontWeight: FontWeight.w500,
            ),
          ),
        ),
      ],
    );
  }

  @override
  Widget build(BuildContext context) {
    return GetBuilder<PersonalInfoController>(
      init: PersonalInfoController(),
      id: "personal_info",
      builder: (_) {
        return Scaffold(
          body: _buildView(),
        );
      },
    );
  }
}
